/*
 * Copyright 2006 Berry Crawford
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.judo.database;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class ChildList
{
	private Class childType;
	private ArrayList children = new ArrayList();
	
	/*
	 * If this class is intantiated with
	 * its empty constructor then it is assumed
	 * that its instantiation will include
	 * the @Children annotation to tell
	 * Judo how to relate the children and
	 * parent 
	 */
	public ChildList()
	{
	}
	
	/*
	 * If this constuctor is used,it is assumed
	 * that the following pattern is true
	 * 
	 *  Entity1 = Parent Type
	 *  Entity2 = Child Type
	 *  
	 *  Entity1 has a single PK named entity1Id
	 *  Entity2 has a reference field to Entity1 named entity1Id of the same type
	 *  
	 *  
	 */
	public ChildList(Class childType)
	{
		this.childType = childType;
	}
	
	public boolean childTypeIsDefined()
	{
		if (childType == null)
			return false;
		else
			return true;
	}
	
	public Class childType()
	{
		return childType;
	}
	
	public void addChild(Object obj)
	{	
	}
	
	public void removeChild()
	{	
	}
	
	public List listAllChildren()
	{
		return children;
	}
	
	public Iterator childIteration()
	{
		return children.iterator();
	}
}
